/**
 * 键盘只能输入数字
 * @param _this 必填
 * @param _stock 可选
 * @returns {Number}
 */
function numberKeyup(_this,_stock){
	var value = $(_this).val();
	value = value.replace(/[^\d]/g,'');
	if(value == '' || value.length == 0){
		value = 1;
	}
	if(_stock != undefined){
		if(value > parseInt(_stock)){
			value = _stock;
			 $.toastWeb({message:'库存不足'});
		}
	}
	return value;
}
/**
 * 强制保留2位小数
 * @param x
 * @returns
 */
function changeTwoDecimal(x) {
    var f_x = parseFloat(x);
    if (isNaN(f_x)) {
        return false;
    }
    var f_x = Math.round(x * 100) / 100;
    var s_x = f_x.toString();
    var pos_decimal = s_x.indexOf('.');
    if (pos_decimal < 0) {
        pos_decimal = s_x.length;
        s_x += '.';
    }
    while (s_x.length <= pos_decimal + 2) {
        s_x += '0';
    }
    return s_x;
}